<template>
  <el-form-item :label="label" :prop="prop" class="any-row">
    <div class="el-border el-files">
      <wd-upload
          v-model="newv"
          :type="type"
          :readonly="readonly"
          :disabled="disabled"
          :max="max"
          :limit="limit"
      ></wd-upload>
    </div>
    <slot></slot>
  </el-form-item>
</template>

<script setup>
import { ref, computed, defineProps, defineEmits } from 'vue';

// Props
const props = defineProps({
  value: Array,
  label: {
    type: String,
    default: "文件",
  },
  prop: {
    type: String,
    default: "files",
  },
  type: {
    type: String,
    default: "files",
  },
  readonly: {
    type: Boolean,
    default: false,
  },
  disabled: {
    type: Boolean,
    default: false,
  },
  max: {
    type: Number,
    default: 200,
  },
  limit: {
    type: Number,
    default: 10,
  },
});

// Emits
const emit = defineEmits();

// Computed for value binding
const newv = computed({
  get: () => props.value,
  set: (value) => emit("update:value", value), // Using `update:value` for v-model
});
</script>
